import java.util.Random;
import java.util.Scanner;

public class Logic {


    public static void main(String[] args) {
        //猜数字游戏
        Scanner scanner = new Scanner(System.in);
        Random random = new Random();
        int num = random.nextInt(100);  //[0,100)
        System.out.println(num);

        while(true){
            System.out.println("请输入要猜的数字：");
            int n = scanner.nextInt();
            if(n>num){
                System.out.println("猜大了");
            }
            else if(n<num){
                System.out.println("猜小了");
            }
            else{
                System.out.println("猜对了，数字是"+num);
                break;
            }
        }

    }

    //循环输入
    public static void main9(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while(scanner.hasNextInt()){     //ctrl+D 结束
            int a = scanner.nextInt();
            System.out.println(a);
        }
    }

    public static void main8(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = scanner.nextLine();
        //String name = scanner.next();     //next遇到空格停止
        System.out.println("姓名"+name);

        //scanner.nextLine();      //前面如果是字符串就不要加这条语句   避免影响下一个数入

        System.out.println("请输入体重：");
        double w = scanner.nextDouble();
        System.out.println("体重"+w);

        scanner.nextLine();

        System.out.println("请输入年龄：");
        int age = scanner.nextInt();
        System.out.println("年龄"+age);
    }

    public static void main7(String[] args) {
        //for循环
//        int i = 0;
//       // for(i=0; ; i++)
//        for(i=0;i<=10;i++){
//            System.out.println(i);
//        }
//        for (int kk = 0; kk < 5; kk++) {
//            System.out.println(kk);
//
//        }

        //阶乘和
        int sum = 0;
        for (int i = 1; i <= 5; i++) {
            int ret = 1;
            for (int j = 1; j <= i; j++) {
                ret*=j;
            }
            sum+=ret;
        }
        System.out.println(sum);

    }

    public static void main6(String[] args) {
        //找出1-100之间能被3整除又能被5整除的数字，使用break或者continue

        int i = 1;
        while(i<=100){
            if(i%3!=0 || i%5!=0){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }

    }

    public static void main5(String[] args) {
        //break continue
        int i = 1;
        int j = 5;
        while(i<=5){
            if(i==3){
               // break;
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
        System.out.println("hello");
    }

    public static void main4(String[] args) {
        //n!
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        int i = 1;
//        int ret = 1;
//        while(i<=n){
//            ret *=i;
//            i++;
//        }
//        System.out.println(ret);
        //1!+2!+3!+……
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int i = 1;
        int a = 1;
        int ret = 0;
        while(i<=n){
            a*=i;
            ret+=a;
            i++;
        }
        System.out.println(ret);
    }

    public static void main3(String[] args) {
        //swich语句
        int day = 1;
        switch(day) {
         case 1:
         System.out.println("星期一");
         break;
         case 2:
         System.out.println("星期二");
         break;
         case 3:
         System.out.println("星期三");
         break;
         case 4:
         System.out.println("星期四");
         break;
         case 5:
         System.out.println("星期五");
          break;
         case 6:
         System.out.println("星期六");
         break;
         case 7:
         System.out.println("星期日");
         break;
         default:
         System.out.println("输入有误");
         break;
        }
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        if(a%2==0){
            System.out.println("偶数");
        }else{
            System.out.println("奇数");
        }
    }

    public static void main1(String[] args) {
        int a = 10;
        if(a==10){

        }
        else if(a!=10){

        }
        else{

        }
    }
}
